Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the search, similar, list, and developer methods #557

Merged
merged 16 commits into from
Jun 23, 2022

Conversation

mmoksh
Copy link
Contributor

@mmoksh mmoksh commented Jun 9, 2022

Google introduced new mapping for the first page of the search results to highlight one app that matches the search query. The rest of the pages have the same mapping as previous.

In this PR, I fixed gplay.search script by updating mappings. I also included the changes from PR #545 that fixes gplay.app in this PR to avoid git conflicts when merging both PRs.

Edit: Added a few more commits to fix the gplay.similar script, and to handle special cases when there is no search results.

Edit2: Added a new commit to fix the gplay.list method.

Use this for testing:

"google-play-scraper": "git+https://github.com/facundoolano/google-play-scraper#pull/557/head"

@mmoksh mmoksh force-pushed the main branch 2 times, most recently from 3a755cb to 76a54ff Compare June 10, 2022 05:43
@Aliaksandr-Kasko-JazzTeam
Copy link
Contributor

Because of changes to GPlay you should update tests to fix failing checks.

@Aliaksandr-Kasko-JazzTeam
Copy link
Contributor

There's no fails with list method, but it returns an empty array for all combinations of category and collection :-\

@NathanManning
Copy link

@mmoksh, did something change? I'm getting empty results again for the clustered apps.

gplay .search({ term: 'facebook', }) .then(console.log, console.log)

returns []

@mmoksh
Copy link
Contributor Author

mmoksh commented Jun 16, 2022

@NathanManning I just checked! It works just fine!
@Aliaksandr-Kasko-JazzTeam This PR does not contain a fix for the gplay.list method. It only fixes the gplay.search and gplay.similar methods. I'll try to update the unit tests later this week.

@Aliaksandr-Kasko-JazzTeam
Copy link
Contributor

@mmoksh could you please fix gplay.list method too? It's really necessary to us

@NathanManning
Copy link

@NathanManning I just checked! It works just fine! @Aliaksandr-Kasko-JazzTeam This PR does not contain a fix for the gplay.list method. It only fixes the gplay.search and gplay.similar methods. I'll try to update the unit tests later this week.

@mmoksh My bad. There's something funky going on in our package-lock.

@mmoksh
Copy link
Contributor Author

mmoksh commented Jun 18, 2022

@Aliaksandr-Kasko-JazzTeam The gplay.list method is fixed now. You might need to delete the package-lock.json file and the node_modules folder to make sure your app is not using an outdated version of this PR.

@mmoksh mmoksh changed the title Fix mappings for search script Fix the search, similar, and list methods Jun 18, 2022
@ninjachen
Copy link

ninjachen commented Jun 20, 2022

Hello, I'm trying to use the new list function of this PR and meet an error, could you help

The steps to reproduce

➜  scraper git:(master) ✗ npm -v
7.24.0
➜  scraper git:(master) ✗ rm -rf node_modules 
➜  scraper git:(master) ✗ rm package-lock.json 
➜  scraper git:(master) ✗ npm install
➜  scraper git:(master) ✗ npx functions-framework --target=list

Serving function...
Function: list
Signature type: http
URL: http://localhost:8080/
Error: Invalid collection topselling_free
    at validate (/Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:43:11)
    at /Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:14:5
    at new Promise (<anonymous>)
    at Object.list (/Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:13:10)
    at exports.list (/Users/ninja/src/lab/scraper/index.js:31:15)
    at /Users/ninja/src/lab/scraper/node_modules/@google-cloud/functions-framework/build/src/invoker.js:98:17
    at processTicksAndRejections (node:internal/process/task_queues:76:11)

package.json

➜  scraper git:(master) ✗ cat package.json 
{
  "name": "scraper",
  "version": "0.5.1",
  "dependencies": {
    "google-play-scraper": "git+https://github.com/facundoolano/google-play-scraper#pull/557/head"
  },
  "scripts": {
    "start": "npx functions-framework --target=app --signature-type=http"
  },
  "devDependencies": {
    "@google-cloud/functions-framework": "1.9.0"
  }
}

@Aliaksandr-Kasko-JazzTeam
Copy link
Contributor

@mmoksh many thanks to you. It seems to work fine. 👍

@facundoolano This PR looks great to merge into master and new package version

@mmoksh
Copy link
Contributor Author

mmoksh commented Jun 22, 2022

Hello, I'm trying to use the new list function of this PR and meet an error, could you help

The steps to reproduce

➜  scraper git:(master) ✗ npm -v
7.24.0
➜  scraper git:(master) ✗ rm -rf node_modules 
➜  scraper git:(master) ✗ rm package-lock.json 
➜  scraper git:(master) ✗ npm install
➜  scraper git:(master) ✗ npx functions-framework --target=list

Serving function...
Function: list
Signature type: http
URL: http://localhost:8080/
Error: Invalid collection topselling_free
    at validate (/Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:43:11)
    at /Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:14:5
    at new Promise (<anonymous>)
    at Object.list (/Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:13:10)
    at exports.list (/Users/ninja/src/lab/scraper/index.js:31:15)
    at /Users/ninja/src/lab/scraper/node_modules/@google-cloud/functions-framework/build/src/invoker.js:98:17
    at processTicksAndRejections (node:internal/process/task_queues:76:11)

package.json

➜  scraper git:(master) ✗ cat package.json 
{
  "name": "scraper",
  "version": "0.5.1",
  "dependencies": {
    "google-play-scraper": "git+https://github.com/facundoolano/google-play-scraper#pull/557/head"
  },
  "scripts": {
    "start": "npx functions-framework --target=app --signature-type=http"
  },
  "devDependencies": {
    "@google-cloud/functions-framework": "1.9.0"
  }
}

I think topselling_free collection is not available on Google Play anymore. I could see Top free, Top grossing, and Top paid on the website, but not top selling. I updated the tests to avoid this error.

@mmoksh mmoksh changed the title Fix the search, similar, and list methods Fix the search, similar, list, and developer methods Jun 22, 2022
@dave-filion
Copy link

@mmoksh thanks so much for this!

@facundoolano
Copy link
Owner

@mmoksh thanks for this.

This one PR addresses all the methods right? I'll set aside some time to review it, merge and publish a new version of the package. Please let me know if there something missing or broken still that I should take into account (I can't keep up with all the conversations going on in issues and PRs)

lib/app.js Outdated Show resolved Hide resolved
lib/utils/appList.js Outdated Show resolved Hide resolved
test/lib.app.js Outdated Show resolved Hide resolved
@mmoksh
Copy link
Contributor Author

mmoksh commented Jun 23, 2022

@mmoksh thanks for this.

This one PR addresses all the methods right? I'll set aside some time to review it, merge and publish a new version of the package. Please let me know if there something missing or broken still that I should take into account (I can't keep up with all the conversations going on in issues and PRs)

Sure!
The PR covers all the methods.

@mmoksh mmoksh requested a review from facundoolano June 23, 2022 01:12
lib/list.js Outdated Show resolved Hide resolved
lib/app.js Outdated Show resolved Hide resolved
const { BASE_URL } = require('./constants');
const { processFullDetailApps } = require('./utils/processPages');

function getBodyForRequests (collection, category) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this function different from the one in utils/processPages ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body content and structure is different. We also pass different parameters here like the collection and category, not the token.

test/lib.app.js Outdated Show resolved Hide resolved
test/lib.app.js Outdated Show resolved Hide resolved
@facundoolano facundoolano merged commit e1e5439 into facundoolano:main Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants